﻿@model  PagedList.IPagedList<MVC3MusicStore.Models.Album>
@if (IsAjax)
{
    Layout = null;
}
@helper Truncate(string input, int length)
    {
        if (input.Length <= length)
        {
    @input
        }
        else
        {
    @input.Substring(0, length)<text>...</text>

        }
}
@{
    ViewBag.Title = "StoreManager";
    ViewBag.Active = "StoreManager";
}
@using MVC3MusicStore.Helpers
<div class="row-fluid">
    <h2>Index</h2>
    <a href="/StoreManager/Create" class="btn btn-primary">
    <i class="icon-plus-sign"></i>
    Create New</a>
 @*   @Html.ActionLink((string)ViewBag.CreateLink, "Create")*@
</div>
<div class="row-fluid" style="margin:20px 0;">
    显示:
    @if (ViewBag.CurrentFilter != "")
    {
 
        @Ajax.ActionLink("All", "Index", new
           {
               sortOrder = ViewBag.CurrentSortOrder,
               Keyword = ViewBag.CurrentKeyword
           }, new AjaxOptions
           {
               UpdateTargetId = "main"
           })
    }
    else
    {
        @:All
                                                }
    &nbsp; | &nbsp;
    @if (ViewBag.CurrentFilter != "Less")
    {
        @Ajax.ActionLink("Less than 10", "Index", new
   {
       filter = "Less",
       sortOrder = ViewBag.CurrentSortOrder,
       Keyword = ViewBag.CurrentKeyword
   }, new AjaxOptions
   {
       UpdateTargetId = "main"
   })
    }
    else
    {
        @:Less than 10
                    }
    &nbsp; | &nbsp;
    @if (ViewBag.CurrentFilter != "Greater")
    {
        @Ajax.ActionLink("Greater than 10", "Index", new
   {
       filter = "Greater",
       sortOrder = ViewBag.CurrentSortOrder,
       Keyword = ViewBag.CurrentKeyword
   }, new AjaxOptions
   {
       UpdateTargetId = "main"
   })
    }
    else
    {
        @:Greater than 10
                    }
</div>
<div class="row-fluid">
@using (Ajax.BeginForm("Index",
   new AjaxOptions { UpdateTargetId = "main" }))
{  
    <input type="text" id="Keyword" name="Keyword" />
    <input type="submit" class="btn btn-primary" value="搜索" />
}
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('#form0').addClass('form-horizontal');
    });
</script>
 
<div class="well">
<table class="table">
    <thead> 
        <tr>
        <th>
            @Ajax.ActionLink((string)ViewBag.GenreDisplay, "Index", new
       {
           sortOrder = ViewBag.GenreSortParam,
           filter = ViewBag.CurrentFilter,
           Keyword = ViewBag.CurrentKeyword
       }, new AjaxOptions
       {
           UpdateTargetId = "main"
       })
        </th>
        <th>
            @Ajax.ActionLink((string)ViewBag.ArtistDisplay, "Index", new
       {
           sortOrder = ViewBag.ArtistSortParam,
           filter = ViewBag.CurrentFilter,
           Keyword = ViewBag.CurrentKeyword
       }, new AjaxOptions
       {
           UpdateTargetId = "main"
       })
        </th>
        <th>
            @Ajax.ActionLink((string)ViewBag.TitleDisplay, "Index", new
       {
           sortOrder = ViewBag.TitleSortParam,
           filter = ViewBag.CurrentFilter,
           Keyword = ViewBag.CurrentKeyword
       }, new AjaxOptions
       {
           UpdateTargetId = "main"
       })
        </th>
        <th>
            @Ajax.ActionLink((string)ViewBag.PriceDisplay, "Index", new
       {
           sortOrder = ViewBag.PriceSortParam,
           filter = ViewBag.CurrentFilter,
           Keyword = ViewBag.CurrentKeyword
       }, new AjaxOptions
       {
           UpdateTargetId = "main"
       })
        </th>
        @*<th>
            AlbumArtUrl
        </th>*@
        <th>
        </th>
    </tr>
    </thead> 
    <tbody>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @*@item.GenreId*@
                @Html.DisplayFor(modelItem => item.Genre.Name)
            </td>
            <td>
                @*@item.ArtistId*@ @*@Html.DisplayFor(modelItem => item.Artist.Name)*@
                @Truncate(item.Artist.Name, 25)
            </td>
            <td>
                @*@item.Title*@
                @Truncate(item.Title, 25)
            </td>
            <td>
                @*@String.Format("{0:F}", item.Price)*@
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            @*            <td>
                @item.AlbumArtUrl
            </td>*@
            <td>
                @Html.ActionLink((string)ViewBag.EditLink, "Edit", new { id = item.AlbumId })|
                @Html.ActionLink((string)ViewBag.DetailsLink, "Details", new { id = item.AlbumId })|
                @Html.ActionLink((string)ViewBag.DeleteLink, "Delete", new { id = item.AlbumId })
            </td>
        </tr>
    }
   </tbody>
</table>
</div>
 @Html.Partial("_Paging")    
    
 